<?php
	session_start();
	date_default_timezone_set('Asia/Shanghai');//设置时区
	//判断是否十天免登录的验证
	if (isset($_COOKIE['webkey'])&&!empty($_COOKIE['webkey'])) {
		$link = mysqli_connect('localhost','root','','blog');
		mysqli_set_charset($link,'utf8');

		$webkey=addslashes($_COOKIE['webkey']);//cookie传递过来的值对字符进行转义
		$time=date('Y-m-d H-i-s',time());//获取系统当前的时间
		//查询是否存在一样的密码标记
		$sql="SELECT * FROM login_auto WHERE web_key='{$webkey}' AND end_date>'{$time}'";
		$r=mysqli_query($link,$sql);
		$row=mysqli_fetch_assoc($r);
		// print_r($row);
		//判断是否存在
		if ($row) {
			$sql="SELECT * FROM user WHERE id={$row['user_id']}";
			$r=mysqli_query($link,$sql);
			$row=mysqli_fetch_assoc($r);
			// print_r($row);
			if ($row) {
				$_SESSION['user_id']=$row['id'];
				$_SESSION['user_user']=$row['user'];
				
			}
			
		}

	}

	if (!isset($_SESSION['user_id'])||$_SESSION['user_id']<1) {
		header('location:register.php');
		exit;
	}else{
		header('location:../resumelist.php');
	}

?>